/**
 * @author mrdoob / http://mrdoob.com/
 */
const { ipcRenderer } = require('electron')
var cppModule = require("../third_party/build/Release/projectAccess")

var Viewport = function (editor) {

	var signals = editor.signals;

	var container = new UI.Panel();
	container.setId('viewport');
	container.setPosition('absolute');
	container.add(new Viewport.Info(editor));

	// 创建窗口控件，发送消息到主进程执行
	reply =  ipcRenderer.sendSync('synchronous-message', { message: 'create' })
	cppModule.updateNativeWindow(reply, 10, 10, 400, 300);
			
	signals.windowResize.add(function () {

		// editor.DEFAULT_CAMERA.aspect = container.dom.offsetWidth / container.dom.offsetHeight;
		// editor.DEFAULT_CAMERA.updateProjectionMatrix();

		// camera.aspect = container.dom.offsetWidth / container.dom.offsetHeight;
		// camera.updateProjectionMatrix();

		// renderer.setSize( container.dom.offsetWidth, container.dom.offsetHeight );

		// render();
		ipcRenderer.sendSync('synchronous-message', {
			message: 'resize'});
	});

	return container;
};
